home *** CD-ROM | disk | FTP | other *** search
- #ifndef (DRAGON_ANGLE)
- #declare DRAGON_ANGLE = 90
- #end
-
- #ifndef (DRAGON_SHAPE)
- #declare DRAGON_SHAPE =
- union {
- cylinder { <0, 0, 0>, <1, 0, 0>, 0.1 }
- sphere { <0, 0, 0>, 0.1 }
- sphere { <1, 0, 0>, 0.1 }
- }
- #end
-
- #ifndef (DRAGON_DEPTH)
- #declare DRAGON_DEPTH = 3
- #else
- #declare DRAGON_DEPTH = int(abs(DRAGON_DEPTH))
- #end
-
-
-
- /*
- * compute the bending-order
- */
-
- #if (DRAGON_DEPTH > 0)
- #declare DRAGON_BENDSTRING = "L"
- #declare DRAGON_DEPTH = DRAGON_DEPTH - 1
- #else
- #declare DRAGON_BENDSTRING = ""
- #end
-
- #declare DRAGON_ISODD = 0
- #declare DRAGON_NUMBENDS = DRAGON_DEPTH
-
- #while (DRAGON_NUMBENDS>0)
-
- #declare DRAGON_REVERSE = ""
- #declare DRAGON_LEN = strlen(DRAGON_BENDSTRING)
- #declare DRAGON_STRCNT = 1
-
- #while (DRAGON_STRCNT<DRAGON_LEN+1)
- #declare DRAGON_CHAR = substr(DRAGON_BENDSTRING, DRAGON_STRCNT, 1)
- #if ( strcmp(DRAGON_CHAR,"R") = 0 )
- #declare DRAGON_REVERSE = concat("L", DRAGON_REVERSE)
- #else
- #declare DRAGON_REVERSE = concat("R", DRAGON_REVERSE)
- #end
- #declare DRAGON_STRCNT = DRAGON_STRCNT + 1
- #end
-
-
- #if (DRAGON_ISODD=0)
- #declare DRAGON_BENDSTRING = concat(DRAGON_REVERSE, "R", DRAGON_BENDSTRING)
- #else
- #declare DRAGON_BENDSTRING = concat(DRAGON_BENDSTRING, "L", DRAGON_REVERSE)
- #end
-
- #declare DRAGON_ISODD = 1 - DRAGON_ISODD
- #declare DRAGON_NUMBENDS = DRAGON_NUMBENDS - 1
- #end
-
- #debug concat("\nDRAGON_BENDSTRING is \"", DRAGON_BENDSTRING, "\"\n")
-
-
-
- /*
- * now build the dragon-union
- */
-
- #declare DRAGON_NUMTRANS = strlen(DRAGON_BENDSTRING)
-
- #ifndef (DRAGON_FROM)
- #declare DRAGON_FROM = 0
- #else
- #declare DRAGON_FROM = int(abs(DRAGON_FROM))
- #end
- #declare DRAGON_FROM_TMP = DRAGON_FROM
-
- #ifndef (DRAGON_UPTO)
- #declare DRAGON_UPTO = DRAGON_NUMTRANS
- #else
- #declare DRAGON_UPTO = int(abs(DRAGON_UPTO))
- #end
- #declare DRAGON_UPTO_TMP = DRAGON_UPTO
-
- #declare DRAGON_STRCNT = 1
-
- #declare DRAGON_LASTX = 0
- #declare DRAGON_LASTY = 0
- #declare DRAGON_ROTANGLE = 0
-
- union {
- #if (DRAGON_FROM = 0)
- object {
- DRAGON_SHAPE
- }
- #declare DRAGON_LASTX = 1
- #declare DRAGON_LASTY = 0
- #end
- #while (DRAGON_NUMTRANS > 0)
- #declare DRAGON_CHAR = substr(DRAGON_BENDSTRING, DRAGON_STRCNT, 1)
- #debug concat(DRAGON_CHAR)
-
- #if ( strcmp(DRAGON_CHAR,"R") = 0 )
- #declare DRAGON_ROTANGLE = DRAGON_ROTANGLE + DRAGON_ANGLE
- #else
- #declare DRAGON_ROTANGLE = DRAGON_ROTANGLE - DRAGON_ANGLE
- #end
-
- #if (DRAGON_ROTANGLE = 0)
- #declare DRAGON_RADANGLE = 0
- #else
- #declare DRAGON_RADANGLE = pi/(180/DRAGON_ROTANGLE)
- #end
-
- #declare DRAGON_NEWX = DRAGON_LASTX + ( cos(DRAGON_RADANGLE) )
- #declare DRAGON_NEWY = DRAGON_LASTY + ( sin(DRAGON_RADANGLE) )
-
- #if (DRAGON_FROM <= DRAGON_STRCNT)
- object {
- DRAGON_SHAPE
- rotate <0, 0, DRAGON_ROTANGLE>
- translate <DRAGON_LASTX, DRAGON_LASTY, 0>
- }
- #end
-
- #declare DRAGON_LASTX = DRAGON_NEWX
- #declare DRAGON_LASTY = DRAGON_NEWY
- #declare DRAGON_STRCNT = DRAGON_STRCNT + 1
- #declare DRAGON_NUMTRANS = DRAGON_NUMTRANS - 1
- #declare DRAGON_UPTO = DRAGON_UPTO - 1
- #if (DRAGON_UPTO <= 0)
- #declare DRAGON_NUMTRANS = 0
- #end
- #end
-
- }
-
- #declare DRAGON_FROM = DRAGON_FROM_TMP
- #declare DRAGON_UPTO = DRAGON_UPTO_TMP
-